#ifndef DBOPERATE_H
#define DBOPERATE_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QStringList>

class dboperate : public QObject
{
    Q_OBJECT
public:
    explicit dboperate(QObject *parent = nullptr);
    static dboperate& getInstance();
    void init();
    ~dboperate();

    bool handleRegist(const char *name, const char *pwd);
    bool handleLogin(const char *name, const char *pwd);
    bool handleOffline(const char *name);
    QStringList handleOnlineUsers();
    int handleSearchUser(const char *name);
    int handleAddFriend(const char *addedName, const char *sourceName);
    bool handleAddFriendAgree(const char *addedName, const char *sourceName);
    int getIdByUserName(const char *name);
    QStringList handleFlushFriend(const char *name);
    bool handleDeleteFriend(const char *deletedName, const char *sourceName);

signals:

public slots:
private:
    QSqlDatabase m_db;
};

#endif // DBOPERATE_H
